package com.acwing.partition1;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;

public class AC11背包问题求方案数 {
    private static int MOD = (int) (1e9 + 7);

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] s = reader.readLine().split("\\s+");
        int n = Integer.parseInt(s[0]), v = Integer.parseInt(s[1]);
        int[][] nums = new int[n][2];
        for (int i = 0; i < n; i++) {
            s = reader.readLine().split("\\s+");
            nums[i][0] = Integer.parseInt(s[0]);
            nums[i][1] = Integer.parseInt(s[1]);
        }
        writer.write(dynamicProgramming(nums, v) + "\n");
        writer.flush();
    }

    private static int dynamicProgramming(int[][] nums, int capacity) {
        int[] dp = new int[capacity + 1], count = new int[capacity + 1];
        count[0] = 1;
        for (int i = 0; i < nums.length; i++) {
            int v = nums[i][0], w = nums[i][1];
            for (int j = capacity; j >= v; j--) {
                int sum = 0, maxWeight = Math.max(dp[j], dp[j - v] + w);
                if (maxWeight == dp[j]) sum += count[j];
                if (maxWeight == dp[j - v] + w) sum += count[j - v];
                count[j] = sum % MOD;
                dp[j] = maxWeight;
            }
        }
        //因为不一定是恰好装满，所以需要统计最大值
        int maxWeight = 0, answer = 0;
        for (int i = 0; i <= capacity; i++) maxWeight = Math.max(maxWeight, dp[i]);
        for (int i = 0; i <= capacity; i++) {
            if (maxWeight == dp[i]) answer = (answer + count[i]) % MOD;
        }
        return answer;
    }
}
